var $, tab, skyconsWeather;
layui.config({
    base: "static/admin/js/"
}).use(['bodyTab', 'form', 'element', 'layer', 'jquery'], function () {
    var form = layui.form,
        layer = layui.layer,
        element = layui.element;
    $ = layui.jquery;
    tab = layui.bodyTab({
        openTabNum: "50",  //最大可打开窗口数量
        url: "/admin/user/getUserMenu" //获取菜单json地址
    });
    var testConfigKey = {
        danma01: '1000'
    };

    var updateConditionId = '';
    var updateConditionFiveId = '';
    var rightContent = [];
    var leftContent = [];
    var conditionCount = 0;
    var conditionCountFive = 0;
    var end_fault = 0;
    var end_fault_five = 0;

    /**
     * 定义常量
     * 首先从缓存中获取，如果有就取并显示
     * 如果没有就不显示，选择后需要更新缓存
     */
    var fiveTestBtnListIds = [];
    fiveTestBtnListIds.push("five-code4-test1");
    fiveTestBtnListIds.push("five-code5-test11");
    fiveTestBtnListIds.push("five-code4-test12");
    fiveTestBtnListIds.push("five-code4-test2");
    fiveTestBtnListIds.push("five-code4-test21");
    fiveTestBtnListIds.push("five-code5-test22");
    fiveTestBtnListIds.push("five-code4-test14");
    fiveTestBtnListIds.push("locate_pre_one");
    fiveTestBtnListIds.push("locate_pre_one-2");
    fiveTestBtnListIds.push("five-k-line");
    fiveTestBtnListIds.push("code_three-1");
    fiveTestBtnListIds.push("code_four_2");
    fiveTestBtnListIds.push("locate_pre_two");
    fiveTestBtnListIds.push("locate_pre_three");
    fiveTestBtnListIds.push("locate_pre_three_1");


    /*默认为自动数据模式*/
    let showType= localStorage.getItem("tableShowType");
    if(showType==undefined){
          localStorage.setItem("tableShowType","3");
    }
    if(showType==3){
         $("#handSwitchBtn").attr("checked", false);
    }
    if(showType==4){
           $("#handSwitchBtn").attr("checked", true);
    }


    //----------------------------------------
    form.on('select(fault-error-five)', function (data) {
        isFaultSelectFive = data.value;
        initCombinationTable(3);
        form.render('select');//select是固定写法 不是选择器
    });

    //更换皮肤
    function skins() {
        var skin = window.sessionStorage.getItem("skin");
        if (skin) {  //如果更换过皮肤
            if (window.sessionStorage.getItem("skinValue") != "自定义") {
                var skin = window.sessionStorage.getItem("skin");
                $("body").addClass(skin);
                $(".layui-side").removeAttr("class").addClass("layui-side").addClass("layui-bg-" + skin + "");
            } else {
                $(".layui-layout-admin .layui-header").css("background-color", skin.split(',')[0]);
                // $(".layui-bg-black").css("background-color",skin.split(',')[1]);
                $(".layui-side").removeAttr("class").addClass("layui-side").addClass("layui-bg-" + skin.split(',')[1] + "");
                $(".hideMenu").css("background-color", skin.split(',')[2]);
            }
        }
    }

    skins();
    $(".changeSkin").click(function () {
        layer.open({
            skin: 'layui-layer-molv', //墨绿风格弹窗
            title: "更换皮肤",
            area: ["310px", "280px"],
            type: "1",
            content: '<div class="skins_box">' +
                '<form class="layui-form">' +
                '<div class="layui-form-item">' +
                '<input type="radio" name="skin" value="默认" title="默认" lay-filter="default" checked="">' +
                '<input type="radio" name="skin" value="橙色" title="橙色" lay-filter="orange">' +
                '<input type="radio" name="skin" value="蓝色" title="蓝色" lay-filter="blue">' +
                '<input type="radio" name="skin" value="自定义" title="自定义" lay-filter="custom">' +
                '<div class="skinCustom">' +
                '<input type="text" class="layui-input topColor" name="topSkin" placeholder="顶部颜色" />' +
                '<input type="text" class="layui-input leftColor" name="leftSkin" placeholder="左侧颜色" />' +
                '<input type="text" class="layui-input menuColor" name="btnSkin" placeholder="顶部菜单按钮" />' +
                '</div>' +
                '</div>' +
                '<div class="layui-form-item skinBtn">' +
                '<a href="javascript:;" class="layui-btn layui-btn-small layui-btn-normal" lay-submit="" lay-filter="changeSkin">确定更换</a>' +
                '<a href="javascript:;" class="layui-btn layui-btn-small layui-btn-primary" lay-submit="" lay-filter="noChangeSkin">我再想想</a>' +
                '</div>' +
                '</form>' +
                '</div>',
            success: function (index, layero) {
                var skin = window.sessionStorage.getItem("skin");
                if (window.sessionStorage.getItem("skinValue")) {
                    $(".skins_box input[value=" + window.sessionStorage.getItem("skinValue") + "]").attr("checked", "checked");
                }
                ;
                if ($(".skins_box input[value=自定义]").attr("checked")) {
                    $(".skinCustom").css("visibility", "inherit");
                    $(".topColor").val(skin.split(',')[0]);
                    $(".leftColor").val(skin.split(',')[1]);
                    $(".menuColor").val(skin.split(',')[2]);
                }
                ;
                form.render();
                $(".skins_box").removeClass("layui-hide");
                $(".skins_box .layui-form-radio").on("click", function () {
                    var skinColor;
                    if ($(this).find("div").text() == "橙色") {
                        skinColor = "orange";
                    } else if ($(this).find("div").text() == "蓝色") {
                        skinColor = "blue";
                    } else if ($(this).find("div").text() == "默认") {
                        skinColor = "black";
                    }
                    if ($(this).find("div").text() != "自定义") {
                        $(".topColor,.leftColor,.menuColor").val('');
                        $("body").removeAttr("class").addClass("main_body " + skinColor + "");
                        $(".skinCustom").removeAttr("style");
                        $(".layui-bg-black,.hideMenu,.layui-layout-admin .layui-header").removeAttr("style");
                        $(".layui-side").removeAttr("class").addClass("layui-side").addClass("layui-bg-" + skinColor + "");
                    } else {
                        $(".skinCustom").css("visibility", "inherit");
                    }
                })
                var skinStr, skinColor;
                $(".topColor").blur(function () {
                    $(".layui-layout-admin .layui-header").css("background-color", $(this).val());
                })
                $(".leftColor").blur(function () {
                    // $(".layui-bg-black").css("background-color",$(this).val());
                    $(".layui-side").removeAttr("class").addClass("layui-side").addClass("layui-bg-" + $(this).val() + "");
                })
                $(".menuColor").blur(function () {
                    $(".hideMenu").css("background-color", $(this).val());
                })

                form.on("submit(changeSkin)", function (data) {
                    if (data.field.skin != "自定义") {
                        if (data.field.skin == "橙色") {
                            skinColor = "orange";
                        } else if (data.field.skin == "蓝色") {
                            skinColor = "blue";
                        } else if (data.field.skin == "默认") {
                            skinColor = "black";
                        }
                        window.sessionStorage.setItem("skin", skinColor);
                    } else {
                        skinStr = $(".topColor").val() + ',' + $(".leftColor").val() + ',' + $(".menuColor").val();
                        window.sessionStorage.setItem("skin", skinStr);
                        $("body").removeAttr("class").addClass("main_body");
                    }
                    window.sessionStorage.setItem("skinValue", data.field.skin);
                    layer.closeAll("page");
                });
                form.on("submit(noChangeSkin)", function () {
                    $("body").removeAttr("class").addClass("main_body " + window.sessionStorage.getItem("skin") + "");
                    $(".layui-bg-black,.hideMenu,.layui-layout-admin .layui-header").removeAttr("style");
                    skins();
                    layer.closeAll("page");
                });
            },
            cancel: function () {
                $("body").removeAttr("class").addClass("main_body " + window.sessionStorage.getItem("skin") + "");
                $(".layui-bg-black,.hideMenu,.layui-layout-admin .layui-header").removeAttr("style");
                skins();
            }
        })
    })
    //0是修改密码，1是新增用户
    var updateOrAdd = 0;

    $("#addUserOk").click(function () {

        var params = {
            id: $("#user_id").val(),
            password_old: $("#password_old").val(),
            password_new: $("#password_new").val(),
            password_new_confirm: $("#password_new_confirm").val(),
            type: updateOrAdd
        };
        if (updateOrAdd == 1) {
            params.user_name = $("#user_name").val();
            params.nick_name = $("#nick_name").val();
            if (params.nick_name == null || params.nick_name.length == 0) {
                layer.msg("昵称不能为空");
                return;
            }
            if (params.user_name == null || params.user_name.length == 0) {
                layer.msg("用户名不能为空");
                return;
            }
        }
        if (password_new == null || password_new.length == 0) {
            alert("新密码不能为空");
            return;
        }
        if (password_new_confirm == null || password_new_confirm.length == 0) {
            alert("新密码不能为空");
            return;
        }
        //提交到后台到信息
        $.post("/system/user/updatePassword", params, function (res) {
            let msg = '';
            if (res.status == 0) {
                msg = '操作成功';
                layer.msg(msg, {time: 1000}, function () {
                    $('#addUsertionWin').modal('hide');
                })
            } else {
                alert(res.errorMsg);
            }

        });
    });
    //新增用户
    $(".addUser").click(function () {
        $("#oldPassDiv").hide();
        $("#nickNameDiv").show();
        $("#nick_name").text("");
        $("#user_name").text("");
        $('#user_name').removeAttr("readonly");
        $("#addUserLabel").text("新增用户");
        updateOrAdd = 1;
        $('#addUsertionWin').modal('show');
    });


    //修改密码
    $(".alterPass").click(function () {
        $("#nickNameDiv").hide();
        $("#user_name").attr("readonly", "readonly");
        $("#addUserLabel").text("修改密码");
        $("#password_old").show();
        // $("#nick_name").hide();
        updateOrAdd = 0;
        $('#addUsertionWin').modal('show');
    })


    //操作栏的格式化


    //用户管理
    $(".manageUser").click(function () {

        function deleteByIds(id) {
            alert(id);
        }


        $('#userManageModal').modal('show');
        $('#mytable').bootstrapTable("destroy");
        $("#mytable").bootstrapTable({
            url: "/system/user/list",   //请求地址
            method: 'get',
            striped: true, //是否显示行间隔色
            pageNumber: 1, //初始化加载第一页
            pagination: true,//是否分页
            sidePagination: 'server',//server:服务器端分页|client：前端分页
            pageSize: 10,//单页记录数
            pageList: [5, 10, 20],//可选择单页记录数
            showRefresh: false,//刷新按钮
            queryParams: function (params) {//上传服务器的参数
                var temp = {
                    offset: params.offset + 0,// SQL语句起始索引
                    pageNumber: params.limit  // 每页显示数量
                };
                return temp;
            }, columns: [{
                title: 'id',
                field: 'id',
                sortable: false
            }, {
                title: '用户名',
                field: 'loginName',
                sortable: false
            }, {
                title: '昵称',
                field: 'nickName',
                sortable: false
            }, {
                title: '密码',
                field: 'password',
                sortable: false
            }, {
                field: 'cc',
                title: '操作',
                formatter: function actionFormatter(value, row, index) {
                    var id = value;
                    var result = "";
                    result += "<a class='user-del'>删除" +
                        "<i class=\"layui-icon layui-icon-close\"></i>  " +
                        "</a>";
                    return result;
                },
                events: window.operatEvents = {
                    'click .user-del': function (e, value, row, index) {
                        $.post("/system/user/delById", {id: row.id}, function (res) {
                            layer.msg('删除成功');
                            $("#mytable").bootstrapTable('refresh');
                        });
                    }
                }
            },
                {
                    field: 'dd',
                    title: '操作',
                    formatter: function actionFormatter(value, row, index) {
                        var id = value;
                        var result = "";
                        result += "<a class='user-pd-reset'>重置密码" +
                            "</a>";
                        return result;
                    },
                    events: window.operatEvents = {
                        'click .user-pd-reset': function (e, value, row, index) {
                            $.post("/system/user/resetPdById", {id: row.id}, function (res) {
                                layer.msg('重置成功');
                                $("#mytable").bootstrapTable('refresh');
                            });
                        }
                    }
                }
            ]
        })
    });

    //退出
    $(".signOut").click(function () {
        window.sessionStorage.removeItem("menu");
        menu = [];
        window.sessionStorage.removeItem("curmenu");
    })

    //隐藏左侧导航
    $(".hideMenu").click(function () {
        $(".layui-layout-admin").toggleClass("showMenu");
        //渲染顶部窗口
        tab.tabMove();
    })

    //渲染左侧菜单
    tab.render();

    //锁屏
    function lockPage() {
        layer.open({
            title: false,
            type: 1,
            content: '	<div class="admin-header-lock" id="lock-box">' +
                '<div class="admin-header-lock-img"><img src="images/face.jpg"/></div>' +
                '<div class="admin-header-lock-name" id="lockUserName"><shiro:principal property = "nickName"/></div>' +
                '<div class="input_btn">' +
                '<input type="password" class="admin-header-lock-input layui-input" autocomplete="off" placeholder="请输入密码解锁.." name="lockPwd" id="lockPwd" />' +
                '<button class="layui-btn" id="unlock">解锁</button>' +
                '</div>' +
                '<p>请输入“123456”，否则不会解锁成功哦！！！</p>' +
                '</div>',
            closeBtn: 0,
            shade: 0.9
        })
        $(".admin-header-lock-input").focus();
    }

    $(".lockcms").on("click", function () {
        window.sessionStorage.setItem("lockcms", true);
        lockPage();
    })
    // 判断是否显示锁屏
    if (window.sessionStorage.getItem("lockcms") == "true") {
        lockPage();
    }
    // 解锁
    $("body").on("click", "#unlock", function () {
        if ($(this).siblings(".admin-header-lock-input").val() == '') {
            layer.msg("请输入解锁密码！");
            $(this).siblings(".admin-header-lock-input").focus();
        } else {
            if ($(this).siblings(".admin-header-lock-input").val() == "123456") {
                window.sessionStorage.setItem("lockcms", false);
                $(this).siblings(".admin-header-lock-input").val('');
                layer.closeAll("page");
            } else {
                layer.msg("密码错误，请重新输入！");
                $(this).siblings(".admin-header-lock-input").val('').focus();
            }
        }
    });
    $(document).on('keydown', function () {
        if (event.keyCode == 13) {
            $("#unlock").click();
        }
    });

    //手机设备的简单适配
    var treeMobile = $('.site-tree-mobile'),
        shadeMobile = $('.site-mobile-shade')

    treeMobile.on('click', function () {
        $('body').addClass('site-mobile');
    });

    shadeMobile.on('click', function () {
        $('body').removeClass('site-mobile');
    });

    // 添加新窗口
    $("body").on("click", ".layui-nav .layui-nav-item a", function () {
        //如果不存在子级
        if ($(this).siblings().length == 0) {
            addTab($(this));
            $('body').removeClass('site-mobile');  //移动端点击菜单关闭菜单层
        }
        $(this).parent("li").siblings().removeClass("layui-nav-itemed");
    })

    //判断是否处于锁屏状态(如果关闭以后则未关闭浏览器之前不再显示)
    /*    if(window.sessionStorage.getItem("lockcms") != "true" && window.sessionStorage.getItem("showNotice") != "true"){
            showNotice();
        }*/
    // $(".showNotice").on("click",function(){
    //     showNotice();
    // })

    //刷新后还原打开的窗口
    if (window.sessionStorage.getItem("menu") != null) {
        menu = JSON.parse(window.sessionStorage.getItem("menu"));
        curmenu = window.sessionStorage.getItem("curmenu");
        var openTitle = '';
        for (var i = 0; i < menu.length; i++) {
            openTitle = '';
            if (menu[i].icon) {
                if (menu[i].icon.split("-")[0] == 'icon') {
                    openTitle += '<i class="iconfont ' + menu[i].icon + '"></i>';
                } else {
                    openTitle += '<i class="layui-icon">' + menu[i].icon + '</i>';
                }
            }
            openTitle += '<cite>' + menu[i].title + '</cite>';
            openTitle += '<i class="layui-icon layui-unselect layui-tab-close" data-id="' + menu[i].layId + '">&#x1006;</i>';
            element.tabAdd("bodyTab", {
                title: openTitle,
                content: "<iframe src='" + menu[i].href + "' data-id='" + menu[i].layId + "'></frame>",
                id: menu[i].layId
            })
            //定位到刷新前的窗口
            if (curmenu != "undefined") {
                if (curmenu == '' || curmenu == "null") {  //定位到后台首页
                    element.tabChange("bodyTab", '');
                } else if (JSON.parse(curmenu).title == menu[i].title) {  //定位到刷新前的页面
                    element.tabChange("bodyTab", menu[i].layId);
                }
            } else {
                element.tabChange("bodyTab", menu[menu.length - 1].layId);
            }
        }
        //渲染顶部窗口
        tab.tabMove();
    }

    //刷新当前
    $(".refresh").on("click", function () {  //此处添加禁止连续点击刷新一是为了降低服务器压力，另外一个就是为了防止超快点击造成chrome本身的一些js文件的报错(不过貌似这个问题还是存在，不过概率小了很多)
        if ($(this).hasClass("refreshThis")) {
            $(this).removeClass("refreshThis");
            $(".clildFrame .layui-tab-item.layui-show").find("iframe")[0].contentWindow.location.reload(true);
            setTimeout(function () {
                $(".refresh").addClass("refreshThis");
            }, 2000)
        } else {
            layer.msg("您点击的速度超过了服务器的响应速度，还是等两秒再刷新吧！");
        }
    })

    //关闭其他
    $(".closePageOther").on("click", function () {
        if ($("#top_tabs li").length > 2 && $("#top_tabs li.layui-this cite").text() != "后台首页") {
            var menu = JSON.parse(window.sessionStorage.getItem("menu"));
            $("#top_tabs li").each(function () {
                if ($(this).attr("lay-id") != '' && !$(this).hasClass("layui-this")) {
                    element.tabDelete("bodyTab", $(this).attr("lay-id")).init();
                    //此处将当前窗口重新获取放入session，避免一个个删除来回循环造成的不必要工作量
                    for (var i = 0; i < menu.length; i++) {
                        if ($("#top_tabs li.layui-this cite").text() == menu[i].title) {
                            menu.splice(0, menu.length, menu[i]);
                            window.sessionStorage.setItem("menu", JSON.stringify(menu));
                        }
                    }
                }
            })
        } else if ($("#top_tabs li.layui-this cite").text() == "后台首页" && $("#top_tabs li").length > 1) {
            $("#top_tabs li").each(function () {
                if ($(this).attr("lay-id") != '' && !$(this).hasClass("layui-this")) {
                    element.tabDelete("bodyTab", $(this).attr("lay-id")).init();
                    window.sessionStorage.removeItem("menu");
                    menu = [];
                    window.sessionStorage.removeItem("curmenu");
                }
            })
        } else {
            layer.msg("没有可以关闭的窗口了@_@");
        }
        //渲染顶部窗口
        tab.tabMove();
    })
    //关闭全部
    $(".closePageAll").on("click", function () {
        if ($("#top_tabs li").length > 1) {
            $("#top_tabs li").each(function () {
                if ($(this).attr("lay-id") != '') {
                    element.tabDelete("bodyTab", $(this).attr("lay-id")).init();
                    window.sessionStorage.removeItem("menu");
                    menu = [];
                    window.sessionStorage.removeItem("curmenu");
                }
            })
        } else {
            layer.msg("没有可以关闭的窗口了@_@");
        }
        //渲染顶部窗口
        tab.tabMove();
    })


    var five_three = -1;
    //点击排列5的代码3按钮


    $("#cb-table").on('mouseenter', 'tbody tr', function () {
        $(this).css('background-color', '#FFD700');
    });

    $("#cb-table").on('mouseleave', 'tbody tr', function () {
        $(this).css('background-color', '#cae0b9');
    });

    $("#cb-table-five").on('mouseenter', 'tbody tr', function () {
        $(this).css('background-color', '#FFD700');
    });

    $("#cb-table-five").on('mouseleave', 'tbody tr', function () {
        $(this).css('background-color', '#cae0b9');
    });


    function initCombinationTable(type) {
        var start = '', end = '';
        if (type == 3) {
            start = $("#five-fault-start").val();
            end = $("#five-fault-end").val();
        }

        $.post("/stat/getInitCombinationWithFault",
            {
                type: type,
                start: start,
                end: end
            }, function (res) {
                var count = res.data.length;
                if (type == 2) {
                    $("#combination-count").text(count);
                }
                if (type == 3) {
                    $("#combination-count-five").text(count);
                }
                var dataArr = res.data;
                var table;
                if (type == 2) {
                    table = $("#cb-table");
                    conditionCount = dataArr.length;
                    rightContent = [];
                }
                if (type == 3) {
                    table = $("#cb-table-five");
                    conditionCountFive = dataArr.length;
                    leftContent = [];
                }
                table.empty();
                for (var i = 0; i < dataArr.length; i++) {
                    let obj = dataArr[i];
                    let arrTemp = obj.split("-");
                    var trStr = "<tr>" +
                        "<td>" + arrTemp[0] + "</td>" +
                        "<td>" + arrTemp[1] + "</td>" +
                        "<td>" + arrTemp[2] + "</td>" +
                        "</tr>";
                    table.append(trStr);
                    if (type == 2) {
                        rightContent.push(arrTemp[0] + " " + arrTemp[1] + " " + arrTemp[2]);
                    }
                    if (type == 3) {
                        leftContent.push(arrTemp[0] + "" + arrTemp[1] + "" + arrTemp[2]);
                    }
                }
            });
    }


    /**
     处理胆码条件修改
     */
    function handlerDanMa(regions, occurs, uuid) {
        var regionArr = regions.split(",");
        var occursArr = occurs.split(",");
        //当前修改条件的id
        updateConditionId = uuid;
        //弹出修改窗,动态复制
        $('#danmaConditionWin').modal('show');
        //
        $("#danmaConditionWin input:checkbox[name='region']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, regionArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#danmaConditionWin input:checkbox[name='occurs']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, occursArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });

    }

    /**
     * 排列5的定位码 handlerDingweimaFive
     */

    function conditionWinCheckSelected(winId, cbName, dataArr) {
        if (dataArr.length == 0) {
            return;
        }
        $("#" + winId + " input:checkbox[name='" + cbName + "']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, dataArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
    }

    function handlerDingweimaFive(firsts, seconds, thirds, occurs, uuid) {
        updateConditionId = uuid;
        var firstArr = firsts.split(",");
        var secondArr = seconds.split(",");
        var thirdArr = thirds.split(",");
        var occurs = occurs.split(",");
        $('#dingweimaConditionFiveWin').modal('show');
        $("#dingweimaConditionFiveWin input:checkbox[name='first']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, firstArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#dingweimaConditionFiveWin input:checkbox[name='second']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, secondArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#dingweimaConditionFiveWin input:checkbox[name='third']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, thirdArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#dingweimaConditionFiveWin input:checkbox[name='occurs']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, occurs) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
    }

    /**
     * 修改定位码的条件
     * @param firsts
     * @param seconds
     * @param thirds
     * @param occurs
     * @param uuid
     */
    function handlerDingweima(firsts, seconds, thirds, occurs, uuid) {
        updateConditionId = uuid;
        var firstArr = firsts.split(",");
        var secondArr = seconds.split(",");
        var thirdArr = thirds.split(",");
        var occurs = occurs.split(",");
        $('#dingweimaConditionWin').modal('show');
        $("#dingweimaConditionWin input:checkbox[name='first']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, firstArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#dingweimaConditionWin input:checkbox[name='second']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, secondArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#dingweimaConditionWin input:checkbox[name='third']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, thirdArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#dingweimaConditionWin input:checkbox[name='occurs']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, occurs) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
    }

    function getCheckValuesFromModal(modalId, cbName) {
        var str = "";
        $("#" + modalId + " input:checkbox[name='" + cbName + "']:checked").each(function () {
            str += $(this).val() + ",";
        });
        if (str.length > 0 && str.substr(str.length - 1) == ',') {
            str = str.substring(0, str.length - 1);
        }
        return str;
    }

    var clipboard = new ClipboardJS('#copyRight', {
        text: function () {
            return rightContent.join("\n");
        }
    });
    $("#copyRight").click(function () {
        layer.msg('复制成功');
    });

    var clipboard = new ClipboardJS('#copyLeft', {
        text: function () {
            return leftContent.join("\n");
        }
    });
    $("#copyLeft").click(function () {
        layer.msg('复制成功');
    });


    /**
     * 对排列5龙头凤尾对条件修改点击确定
     */
    $("#dragonFiveOk").click(function () {
        var head = getCheckValuesFromModal("dragonConditionFiveWin",
            "head");
        var tail = getCheckValuesFromModal("dragonConditionFiveWin",
            "tail");
        var htoccur = getCheckValuesFromModal("dragonConditionFiveWin",
            "htoccur");
        if (head.length > 0) {
            head = "1:" + head;
        }
        if (tail.length > 0) {
            tail = "0:" + tail;
        }
        var headAndTail = head + ";" + tail + ";" + htoccur;
        var dragonArea = getCheckValuesFromModal("dragonConditionFiveWin",
            "dragonArea");
        var phoenArea = getCheckValuesFromModal("dragonConditionFiveWin",
            "phoenArea");
        var area0 = getCheckValuesFromModal("dragonConditionFiveWin",
            "area0");
        var area1 = getCheckValuesFromModal("dragonConditionFiveWin",
            "area1");
        var area2 = getCheckValuesFromModal("dragonConditionFiveWin",
            "area2");
        var occurs = getCheckValuesFromModal("dragonConditionFiveWin",
            "occurs");
        //必须选一个出几
        if (occurs.length == 0) {
            alert("wrong select");
            return;
        }
        if ((head != '' || tail != '') && htoccur == '') {
            alert("wrong select");
            return;
        }
        if (dragonArea.length == 0 && phoenArea.length == 0 &&
            area0.length == 0 && area1.length == 0 && area2.length == 0
            && head.length == 0 && tail.length == 0
        ) {
            alert("wrong select");
            return;
        }
        var params = {
            headAndTail: headAndTail,
            headArea: dragonArea,
            tailArea: phoenArea,
            area0: area0,
            area1: area1,
            area2: area2,
            occurs: occurs,
            uuid: updateConditionFiveId,
            type: 3

        };
        $.post("/dragon/dragonConditionChange", params, function (res) {
            $('#dragonConditionFiveWin').modal('hide');
            location.reload();

        });

    });


    /**
     * 对定位码的修改确定定义点击事件
     */
    $("#dingweimaOk").click(function () {
        var firsts = getCheckValuesFromModal("dingweimaConditionWin", "first");
        var seconds = getCheckValuesFromModal("dingweimaConditionWin", "second");
        var thirds = getCheckValuesFromModal("dingweimaConditionWin", "third");
        var occurs = getCheckValuesFromModal("dingweimaConditionWin", "occurs");
        //第一位,第二位,第三位必须选一个
        if (occurs.length == 0 || (firsts.length == 0 && seconds.length == 0 && thirds.length == 0)) {
            alert("wrong select");
        } else {
            var params = {
                firstPredict: firsts,
                secondPredict: seconds,
                thirdPredict: thirds,
                occurTimes: occurs,
                uuid: updateConditionId,
                type: 2
            };
            $.post("/stat/dingweimaConditionChange", params, function (res) {
                $('#dingweimaConditionWin').modal('hide');
                location.reload();
            });
        }


    });

    $("#dingweimaFiveOk").click(function () {
        var firsts = getCheckValuesFromModal("dingweimaConditionFiveWin", "first");
        var seconds = getCheckValuesFromModal("dingweimaConditionFiveWin", "second");
        var thirds = getCheckValuesFromModal("dingweimaConditionFiveWin", "third");
        var occurs = getCheckValuesFromModal("dingweimaConditionFiveWin", "occurs");
        //第一位,第二位,第三位必须选一个
        if (occurs.length == 0 || (firsts.length == 0 && seconds.length == 0 && thirds.length == 0)) {
            alert("wrong select");
        } else {
            var params = {
                firstPredict: firsts,
                secondPredict: seconds,
                thirdPredict: thirds,
                occurTimes: occurs,
                uuid: updateConditionId,
                type: 3
            };
            $.post("/stat/dingweimaConditionChange", params, function (res) {
                $('#dingweimaConditionWin').modal('hide');
                location.reload();
            });
        }


    });

    /**
     * 排列5胆码条件修改确定
     */
    $("#danmaOkFive").click(function () {
        var regions = getCheckValuesFromModal("danmaConditionWinFive", "region");
        var occurs = getCheckValuesFromModal("danmaConditionWinFive", "occurs");
        //没有选择，不操作
        if (regions.length == 0 || occurs.length == 0) {
            alert("wrong select");
        } else {
            var params = {
                regions: regions,
                occurs: occurs,
                uuid: updateConditionFiveId,
                type: 3
            };
            $.post("/stat/danmaConditionChange", params, function (res) {
                $('#danmaConditionWinFive').modal('hide');
                location.reload();
            });
        }
    });

    /**
     * 胆码条件修改确定
     */
    $("#danmaOk").click(function () {
        var regions = getCheckValuesFromModal("danmaConditionWin", "region");
        var occurs = getCheckValuesFromModal("danmaConditionWin", "occurs");
        //没有选择，不操作
        if (regions.length == 0 || occurs.length == 0) {
            alert("wrong select");
        } else {
            var params = {
                regions: regions,
                occurs: occurs,
                uuid: updateConditionId,
                type: 2
            };
            $.post("/stat/danmaConditionChange", params, function (res) {
                $('#danmaConditionWin').modal('hide');
                location.reload();
            });
        }
    });

    /**
     * 处理龙头凤尾选择条件
     */
    function handlerDragonPhoen(conditions, uuid, type) {
        if (type == 2) {
            updateConditionId = uuid;
            $('#dragonConditionWin').modal('show');
        }
        if (type == 3) {
            updateConditionFiveId = uuid;
            $('#dragonConditionFiveWin').modal('show');
        }

        var arr = conditions.split(";");
        var dragonAndTail = arr[1];
        var dtArr = dragonAndTail.split("-");
        var dragon = dtArr[0];
        if (dragon.split(":").length == 2) {
            var a2 = dragon.split(":")[1];
            if (type == 2) {
                $("#head_" + a2).prop("checked", true);
            }
            if (type == 3) {
                $("#headFive_" + a2).prop("checked", true);
            }
        }
        var tail = dtArr[1];
        if (tail.split(":").length == 2) {
            var b2 = tail.split(":")[1];
            if (type == 2) {
                $("#tail_" + b2).prop("checked", true);
            }
            if (type == 3) {
                $("#tailFive_" + b2).prop("checked", true);
            }
        }
        var dtOccur = dtArr[2];
        if (dtOccur.length > 0) {
            var arrTemp = dtOccur.split(",");
            for (x in arrTemp) {
                if (x.length > 0) {
                    if (type == 2) {
                        $("#htoccur_" + arrTemp[x]).prop("checked", true);
                    }
                    if (type == 3) {
                        $("#htoccurFive_" + arrTemp[x]).prop("checked", true);
                    }
                }
            }
        }
        //龙头012路 dragonArea
        var headArea = arr[2];
        var headAreaArr = headArea.split(",");
        for (x in headAreaArr) {
            if (x.length > 0) {
                if (type == 2) {
                    $("#dragonArea_" + headAreaArr[x]).prop("checked", true);
                }
                if (type == 3) {
                    $("#dragonAreaFive_" + headAreaArr[x]).prop("checked", true);
                }

            }
        }
        //凤尾012路
        var headArea = arr[3];
        var headAreaArr = headArea.split(",");
        for (x in headAreaArr) {
            if (x.length > 0) {
                if (type == 2) {
                    $("#phoenArea_" + headAreaArr[x]).prop("checked", true);
                }
                if (type == 3) {
                    $("#phoenAreaFive_" + headAreaArr[x]).prop("checked", true);
                }
            }
        }
        //o路个数 area1_0
        var area0 = arr[4];
        var area0Arr = area0.split(",");
        for (x in area0Arr) {
            if (x.length > 0) {
                if (type == 2) {
                    $("#area0_" + area0Arr[x]).prop("checked", true);
                }
                if (type == 3) {
                    $("#area0Five_" + area0Arr[x]).prop("checked", true);
                }
            }
        }
        var area1 = arr[5];
        var area1Arr = area1.split(",");
        for (x in area1Arr) {
            if (x.length > 0) {
                if (type == 2) {
                    $("#area1_" + area1Arr[x]).prop("checked", true);
                }
                if (type == 3) {
                    $("#area1Five_" + area1Arr[x]).prop("checked", true);
                }
            }
        }
        var area2 = arr[6];
        var area2Arr = area2.split(",");
        for (x in area2Arr) {
            if (x.length > 0) {
                if (type == 2) {
                    $("#area2_" + area2Arr[x]).prop("checked", true);
                }
                if (type == 3) {
                    $("#area2Five_" + area2Arr[x]).prop("checked", true);
                }
            }
        }
        //occurs_6
        var occurs = arr[7];
        var occursArr = occurs.split(",");
        for (x in occursArr) {
            if (x.length > 0) {
                if (type == 2) {
                    $("#occurs_" + occursArr[x]).prop("checked", true);
                }
                if (type == 3) {
                    $("#occursFive_" + occursArr[x]).prop("checked", true);
                }
            }
        }

    }

    /**
     * 代码3条件修改
     */

    $("#code3ValueOk").click(function () {
        var firstValue = getCheckValuesFromModal("code3ConditionWin",
            "firstValue");
        var firstOccur = getCheckValuesFromModal("code3ConditionWin",
            "firstOccur");
        var secondValue = getCheckValuesFromModal("code3ConditionWin",
            "secondValue");
        var secondOccur = getCheckValuesFromModal("code3ConditionWin",
            "secondOccur");
        var thirdValue = getCheckValuesFromModal("code3ConditionWin",
            "thirdValue");
        var thirdOccur = getCheckValuesFromModal("code3ConditionWin",
            "thirdOccur");
        var occurs = getCheckValuesFromModal("code3ConditionWin",
            "code3Occur");
        var code_type = $("#codeType").val();


        if (occurs.length == 0) {
            alert("wrong select");
        } else {
            var url = "/codeThree/code3ConditionChange";
            if (code_type == 101 || code_type == 102) {
                url = "/codeFive/code5ConditionChange";
            }
            if (code_type == 104) {
                url = "/codeThree/code3ConditionChange";
            }
            var params = {
                firsts: firstValue,
                firstOccurs: firstOccur,
                seconds: secondValue,
                secondOccurs: secondOccur,
                thirds: thirdValue,
                thirdOccurs: thirdOccur,
                occurs: occurs,
                uuid: updateConditionId,
                type: code_type,
                dataType: code_type == 100 || code_type == 104 ? 3 : 2
            };
            //提交到后台到信息
            $.post(url, params, function (res) {
                layer.msg('成功将您预测的号码提交到"已选条件"里面!', {time: 1000}, function () {
                    layer.close(layer.index);
                    parent.location.reload();
                })
            });

        }


    });

    //和合值修改确定
    $("#sumValueOk").click(function () {
        var values = getCheckValuesFromModal("sumValueConditionWin",
            "sumValue");
        var occurs = getCheckValuesFromModal("sumValueConditionWin",
            "occurs");
        var firstTemp = $("#sumValueConditionWin input[type=checkbox][name='first']:checked");
        var secondTemp = $("#sumValueConditionWin input[type=checkbox][name='second']:checked")
        var first = firstTemp.val();
        var second = secondTemp.val();
        if (occurs.length == 0) {
            alert("wrong select");
        } else {
            if (first == 0) {
                first = '左';
            } else if (first == 1) {
                first = '断';
            } else if (first == 2) {
                first = '右';
            }
            if (second == 0) {
                second = '断';
            } else if (second == 1) {
                second = '落';
            }
            var params = {
                sumValues: values,
                valueFirst: first,
                valueSecond: second,
                occurs: occurs,
                uuid: updateConditionId
            };
            $.post("/sum/sumValueConditionChange", params, function (res) {
                $('#sumValueConditionWin').modal('hide');
                location.reload();

            });

        }


    });

    function handlerSumValue(arraAll, uuid) {
        updateConditionId = uuid;
        $('#sumValueConditionWin').modal('show');
        var sumValues = arraAll[1];
        if (sumValues.length > 0) {
            var arr = sumValues.split(",");
            for (var i = 0; i < arr.length; i++) {
                $("#sumValue_" + arr[i]).prop("checked", true);
            }
        }
        var value1 = arraAll[2];
        if (value1.length > 0) {
            if (value1 == '断') {
                $("#break1").prop("checked", true);
            } else if (value1 == '左') {
                $("#leftPass").prop("checked", true);
            } else if (value1 == '右') {
                $("#rightPass").prop("checked", true);
            }
        }
        var value2 = arraAll[3];
        if (value2.length > 0) {
            if (value2 == '断') {
                $("#break2").prop("checked", true);
            } else if (value2 == '落') {
                $("#fall").prop("checked", true);
            }
        }
        var occus = arraAll[4];
        if (occus.length > 0) {
            var arr = occus.split(",");
            for (var i = 0; i < arr.length; i++) {
                $("#sumValueOccur_" + arr[i]).prop("checked", true);
            }
        }


    }

    /**
     * 根据id 设置checkbox的值
     * @param strs
     * @param idPrefix
     */
    function setCheckBoxValueByIdPreFix(strs, idPrefix) {
        if (strs.length > 0) {
            var arr = strs.split(",");
            for (var i = 0; i < arr.length; i++) {
                $("#" + idPrefix + "" + arr[i]).prop("checked", true);
            }
        }
    }



    /**
     * 边临走势编辑提交
     *  $("#").click(function () {
     */
    $("#borderValueOk").click(function () {
        //alert();
        var maxIntervals = getCheckValuesFromModal("borderConditionWin",
            "maxIntervals");
        var borderSums = getCheckValuesFromModal("borderConditionWin",
            "borderSums");
        var distances = getCheckValuesFromModal("borderConditionWin",
            "distances");
        var valueFirst = getCheckValuesFromModal("borderConditionWin",
            "first");
        var valueSecond = getCheckValuesFromModal("borderConditionWin",
            "second");
        var occursAll = getCheckValuesFromModal("borderConditionWin",
            "occurs");
        var occursMix = getCheckValuesFromModal("borderConditionWin",
            "mixOccur");

        //总的出现次数必须选择
        if (occursAll.length == 0) {
            layer.msg('所选项不能为空');
            return;
        } else {
            // 3 类  默认 1 2  。没有3 。选项就是0  1  2
            var params = {
                distances: distances,//反边球 1
                maxIntervals: maxIntervals,//最大临码 2
                borderSums: borderSums,//边临和 3
                valueFirst: valueFirst,//传断  3
                valueSecond: valueSecond,//断落  3
                occursAll: occursAll,
                occursMix: occursMix,// 3 组的occurs
                uuid: updateConditionId
            };
            //提交到后台到信息
            $.post("/border/borderConditionChange", params, function (res) {
                layer.msg('成功将您预测的号码提交到"已选条件"里面!', {time: 1000}, function () {
                    layer.close(layer.index);
                    parent.location.reload();
                })
            });
        }


    });

    /**
     * 互斥
     */
    $("#borderConditionWin input[type=checkbox][name='second']").change(function () {
        var obj = $(this);
        if (obj.prop("checked")) {
            $("#borderConditionWin input[type=checkbox][name='second']").not(this).attr("checked", false);
        }
    });
    $("#borderConditionWin input[type=checkbox][name='first']").change(function () {
        var obj = $(this);
        if (obj.prop("checked")) {
            $("#borderConditionWin input[type=checkbox][name='first']").not(this).attr("checked", false);
        }
    });

    /**
     * 跨度传落条件修改单选限制
     */
    $("#spanConditionWin input[type=checkbox][name='firstSpan']").change(function () {
        var obj = $(this);
        if (obj.prop("checked")) {
            $("#spanConditionWin input[type=checkbox][name='firstSpan']").not(this).attr("checked", false);
        }
    });
    $("#spanConditionWin input[type=checkbox][name='secondSpan']").change(function () {
        var obj = $(this);
        if (obj.prop("checked")) {
            $("#spanConditionWin input[type=checkbox][name='secondSpan']").not(this).attr("checked", false);
        }
    });


    //代码3 北京飞艇
    function handlerCode3Value(arrResult, uuid) {
        updateConditionId = uuid;
        $('#code3ConditionWin').modal('show');
        $("#codeType").val(arrResult[0]);

        if (arrResult[0] == 7) {
            $("#code3Label").text("代码3走势");
        }
        if (arrResult[0] == 8) {
            $("#code3Label").text("代码4走势");
        }
        if (arrResult[0] == 11) {
            $("#code3Label").text("代码5走势");
        }

        $("#thirdLabel0").hide();
        $("#secondLabel0").hide();
        $("#firstLabel0").hide();

        $("#thirdLabel10").show();
        $("#secondLabel10").show();
        $("#firstLabel10").show();

        setCheckBoxValueByIdPreFix(arrResult[1], "firstValue_");
        setCheckBoxValueByIdPreFix(arrResult[2], "firstOccur_");
        setCheckBoxValueByIdPreFix(arrResult[3], "secondValue_");
        setCheckBoxValueByIdPreFix(arrResult[4], "secondOccur_");
        setCheckBoxValueByIdPreFix(arrResult[5], "thirdValue_");
        setCheckBoxValueByIdPreFix(arrResult[6], "thirdOccur_");
        setCheckBoxValueByIdPreFix(arrResult[7], "code3Occur_");
    }

    /**
     *跨度传落
     */
    function handlerSpanValue(arrResult, uuid) {
        updateConditionId = uuid;
        $('#spanConditionWin').modal('show');
        setCheckBoxValueByIdPreFix(arrResult[1], "spanValue_");
        setCheckBoxValueByIdPreFix(arrResult[4], "spanOccur_");
        var value1 = arrResult[2];
        if (value1.length > 0) {
            if (value1 == 'break1') {
                $("#break1Span").prop("checked", true);
            } else if (value1 == 'left') {
                $("#leftPassSpan").prop("checked", true);
            } else if (value1 == 'right') {
                $("#rightPassSpan").prop("checked", true);
            }
        }

        var value2 = arrResult[3];
        if (value2.length > 0) {
            if (value2 == 'break2') {
                $("#break2Span").prop("checked", true);
            } else if (value2 == 'fall') {
                $("#fallSpan").prop("checked", true);
            }
        }

    }

    /**
     * 边临走势
     */
    function handlerBorderSum(arrResult, uuid) {
        updateConditionId = uuid;
        $('#borderConditionWin').modal('show');
        setCheckBoxValueByIdPreFix(arrResult[1], "distances_");
        setCheckBoxValueByIdPreFix(arrResult[2], "maxInterval_");
        setCheckBoxValueByIdPreFix(arrResult[3], "borderSums_");
        setCheckBoxValueByIdPreFix(arrResult[7], "mixOccur_");
        setCheckBoxValueByIdPreFix(arrResult[6], "borderOccur_");


        var value1 = arrResult[4];
        if (value1.length > 0) {
            if (value1 == 'break1') {
                $("#break1Border").prop("checked", true);
            } else if (value1 == 'left') {
                $("#leftPassBorder").prop("checked", true);
            } else if (value1 == 'right') {
                $("#rightPassBorder").prop("checked", true);
            }
        }
        var value2 = arrResult[5];
        if (value1.length > 0) {
            if (value2 == 'break2') {
                $("#break2Border").prop("checked", true);
            } else if (value2 == 'fall') {
                $("#fallBorder").prop("checked", true);
            }
        }

    }

    /**
     * 删除条件
     */
    $("#condition-table").on('click', ".del-condition", function () {
        var id = $(this).parent().parent().find(".con-id");
        //去后台删除掉
        $.post("/stat/delConditionById", {id: id.eq(0).val()}, function (res) {
            id.parent().parent().remove();//移除当前的条件行
            initCombinationTable(2);
        });
    });


    /**
     * 删除条件
     */
    $("#condition-table-five").on('click', ".del-condition", function () {
        var id = $(this).parent().parent().find(".con-id");
        //去后台删除掉
        $.post("/stat/delConditionById", {id: id.eq(0).val()}, function (res) {
            id.parent().parent().remove();//移除当前的条件行
            initCombinationTable(3);

        });
    });

    function handlerDanMaFive(regions, occurs, uuid) {
        var regionArr = regions.split(",");
        var occursArr = occurs.split(",");
        //当前修改条件的id
        updateConditionFiveId = uuid;
        //弹出修改窗,动态复制
        $('#danmaConditionWinFive').modal('show');
        //
        $("#danmaConditionWinFive input:checkbox[name='region']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, regionArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });
        $("#danmaConditionWinFive input:checkbox[name='occurs']").each(function () {
            var cbVal = $(this).val();
            if ($.inArray(cbVal, occursArr) >= 0) {
                $(this).prop("checked", true); //标准写法，推荐！
            }
        });

    }

    function handlerPassFive(arr, uuid) {
        updateConditionFiveId = uuid;
        $('#passConditionWinFive').modal('show');
        var continus = arr[1];
        var passes = arr[2];
        var partis = arr[3];
        var falls = arr[4];
        var occurs = arr[5];
        conditionWinCheckSelected('passConditionWinFive', 'continu', continus);
        conditionWinCheckSelected('passConditionWinFive', 'passVal', passes);
        conditionWinCheckSelected('passConditionWinFive', 'partiVal', partis);
        conditionWinCheckSelected('passConditionWinFive', 'fallVal', falls);
        conditionWinCheckSelected('passConditionWinFive', 'occurs', occurs);
    }

    $("#passValOk").click(function () {
        var continus = getCheckValuesFromModal("passConditionWinFive",
            "continu");
        var passes = getCheckValuesFromModal("passConditionWinFive",
            "passVal");
        var partis = getCheckValuesFromModal("passConditionWinFive",
            "partiVal");
        var falls = getCheckValuesFromModal("passConditionWinFive",
            "fallVal");
        var occurs = getCheckValuesFromModal("passConditionWinFive",
            "occurs");

        if (continus.length == 0 && passes.length == 0 && partis.length == 0
            && falls.length == 0) {
            layer.msg('wrong select');
            return;
        }
        if (occurs.length == 0) {
            layer.msg('wrong select');
        } else {

            var params = {
                continus: continus,
                passes: passes,
                partis: partis,
                falls: falls,
                occurs: occurs,
                uuid: updateConditionFiveId
            }
            //提交到后台到信息
            $.post("/stat/passConditionChange", params, function (res) {
                layer.msg('成功将您预测的号码提交到"已选条件"里面!', {time: 1000}, function () {
                    layer.close(layer.index);
                    parent.location.reload();
                })
            });

        }

    });

    /**
     * 排列5代码4条件编辑
     * @param arrResult
     * @param uuid
     */
    function handlerCode4Five(arrResult, uuid) {
        updateConditionId = uuid;
        $('#code3ConditionWin').modal('show');
        $("#codeType").val(100);//排列5的代码4
        $("#code3Label").text("代码4走势");

        $("#thirdLabel0").show();
        $("#secondLabel0").show();
        $("#firstLabel0").show();

        $("#thirdLabel10").hide();
        $("#secondLabel10").hide();
        $("#firstLabel10").hide();

        setCheckBoxValueByIdPreFix(arrResult[1], "firstValue_");
        setCheckBoxValueByIdPreFix(arrResult[2], "firstOccur_");
        setCheckBoxValueByIdPreFix(arrResult[3], "secondValue_");
        setCheckBoxValueByIdPreFix(arrResult[4], "secondOccur_");
        setCheckBoxValueByIdPreFix(arrResult[5], "thirdValue_");
        setCheckBoxValueByIdPreFix(arrResult[6], "thirdOccur_");
        setCheckBoxValueByIdPreFix(arrResult[7], "code3Occur_");
    }

    function handlerCode5(arrResult, uuid, value) {
        updateConditionId = uuid;
        $('#code3ConditionWin').modal('show');
        $("#codeType").val(value);//排列5的代码4
        // if(value=101){
        $("#code3Label").text("代码5走势");
        if (value == 104) {
            $("#code3Label").text("代码3走势");
        }
        // }
        if (value == 101) {
            $("#thirdLabel0").hide();
            $("#secondLabel0").hide();
            $("#firstLabel0").hide();

            $("#thirdLabel10").show();
            $("#secondLabel10").show();
            $("#firstLabel10").show();
        }
        //104表示排列5代码3
        if (value == 102 || value == 104) {
            $("#thirdLabel0").show();
            $("#secondLabel0").show();
            $("#firstLabel0").show();

            $("#thirdLabel10").hide();
            $("#secondLabel10").hide();
            $("#firstLabel10").hide();
        }

        setCheckBoxValueByIdPreFix(arrResult[1], "firstValue_");
        setCheckBoxValueByIdPreFix(arrResult[2], "firstOccur_");
        setCheckBoxValueByIdPreFix(arrResult[3], "secondValue_");
        setCheckBoxValueByIdPreFix(arrResult[4], "secondOccur_");
        setCheckBoxValueByIdPreFix(arrResult[5], "thirdValue_");
        setCheckBoxValueByIdPreFix(arrResult[6], "thirdOccur_");
        setCheckBoxValueByIdPreFix(arrResult[7], "code3Occur_");
    }


    /**
     * 排列5的条件修改
     */
    $("#condition-table-five").on('click', ".edit-condition", function () {
        var idObj = $(this).parent().parent().find(".con-id");
        var uuid = idObj.eq(0).val();
        //获取条件
        $.post("/stat/getConditionByIdFive", {id: uuid}, function (res) {
            var conditions = res.data;
            var arr = conditions.split(";");
            if (arr[0] == 1) {
                var regions = arr[1];
                var occurs = arr[2];
                //胆码
                handlerDanMaFive(regions, occurs, uuid);
            } else if (arr[0] == 3) {
                handlerDragonPhoen(conditions, uuid, 3);
            } else if (arr[0] == 2) {
                var firsts = arr[1];
                var seconds = arr[2]
                var thirds = arr[3];
                var occurs = arr[4];
                //定位码
                handlerDingweimaFive(firsts, seconds, thirds, occurs, uuid);
            } else if (arr[0] == 9) {
                handlerPassFive(arr, uuid);
            } else if (arr[0] == 8) {
                handlerCode4Five(arr, uuid);
                // handlerCode5(arr,uuid,102);
            } else if (arr[0] == 11) {
                handlerCode5(arr, uuid, 102);
            } else if (arr[0] == 12) {
                handlerCode5(arr, uuid, 104);
            }

        });
    });
    /**
     * 修改条件
     */
    $("#condition-table").on('click', ".edit-condition", function () {
        var idObj = $(this).parent().parent().find(".con-id");
        var uuid = idObj.eq(0).val();
        //获取条件
        $.post("/stat/getConditionById", {id: uuid}, function (res) {
            var conditions = res.data;
            var arr = conditions.split(";");
            if (arr[0] == 1) {
                var regions = arr[1];
                var occurs = arr[2];
                //胆码
                handlerDanMa(regions, occurs, uuid);
            } else if (arr[0] == 2) {
                var firsts = arr[1];
                var seconds = arr[2]
                var thirds = arr[3];
                var occurs = arr[4];
                //定位码
                handlerDingweima(firsts, seconds, thirds, occurs, uuid);
            } else if (arr[0] == 3) {
                handlerDragonPhoen(conditions, uuid, 2);
            } else if (arr[0] == 4) {
                handlerSumValue(arr, uuid);
            } else if (arr[0] == 5) {
                handlerBorderSum(arr, uuid);
            } else if (arr[0] == 6) {
                handlerSpanValue(arr, uuid);
            } else if (arr[0] == 7 || arr[0] == 8) {
                handlerCode3Value(arr, uuid);
            } else if (arr[0] == 11) {
                for (let i = 1; i < arr.length; i++) {
                    if (arr[i].substr(0, 1) == '0') {
                        arr[i] = arr[i].substr(1);
                    }
                }
                handlerCode5(arr, uuid, 101);
            }

        });
    });


    var beiJinggetConditions = function () {

        $.post("/stat/getConditions", {}, function (res) {
            var dataArr = res.data;
            var conditionTable = $("#condition-table");
            conditionTable.empty();
            for (var i = 0; i < dataArr.length; i++) {
                var condition = dataArr[i];
                var isFaultHtml = '';
                if (condition.fault) {
                    isFaultHtml = "<input type='checkbox' class='fault-check'  checked name='fault-check'>容错";
                } else {
                    isFaultHtml = "<input type='checkbox' class='fault-check'  name='fault-check'>容错";
                }

                var str = "<tr><td><input class='con-id' type='hidden' value='" + condition.id + "' /> " + condition.type + "</td><td>" + condition.content
                    + "</td><td>" + condition.count + "</td><td>" +
                    //  "<input type='checkbox' class='fault-check'  name='fault-check'>失效" +
                    isFaultHtml +
                    "</td><td> <button type='button'  style='padding: 0px 12px;'  class='edit-condition btn btn-success'>编 辑</button>" +
                    "</td><td><button type='button'   style='padding: 0px 12px;'  class='del-condition btn btn-danger'>删 除</button></td>" +
                    "</tr>";
                conditionTable.append(str);
            }
            //加载完条件再加载数据集合
            initCombinationTable(2);
        });
    }

    var getConditionsFive = function () {
        $.post("/stat/getConditionsFive", {}, function (res) {
            var dataArr = res.data;
            var conditionTable = $("#condition-table-five");
            conditionTable.empty();
            for (var i = 0; i < dataArr.length; i++) {
                var condition = dataArr[i];
                var isFaultHtml = '';
                if (condition.fault) {
                    isFaultHtml = "<input type='checkbox' class='fault-check'  checked name='fault-check'>容错";
                } else {
                    isFaultHtml = "<input type='checkbox' class='fault-check'  name='fault-check'>容错";
                }
                var normalBtnHtml = "</td><td> <button type='button'   style='padding: 0px 12px;'  class='edit-condition btn btn-success'>编 辑</button>";
                if (condition.hideEdit) {
                    normalBtnHtml = "</td><td> <button type='button'  disabled='disabled' style='padding: 0px 12px;'  class='edit-condition btn btn-success'>编 辑</button>";
                }
                var str = "<tr><td><input class='con-id' type='hidden' value='" + condition.id + "' /> " + condition.type + "</td><td>" + condition.content
                    + "</td><td>" + condition.count + "</td><td>" +
                    isFaultHtml +
                    normalBtnHtml +
                    "</td><td><button type='button'   style='padding: 0px 12px;'  class='del-condition btn btn-danger'>删 除</button></td>" +
                    "</tr>";
                conditionTable.append(str);
            }

            //加载完条件再加载数据集合
            initCombinationTable(3);
        });
    }

    function initFaultStartAndEndNum() {
        $.post("/stat/getFaultStartAndEnd", {type:3}, function (res) {
            let start=parseInt(res.data.split(",")[0]);
            let end=parseInt(res.data.split(",")[1]);
           $("#five-fault-start").val(start);
           $("#five-fault-end").val(end);

            beiJinggetConditions();
            getConditionsFive();

        });
    }

    //交集容错数值记忆
    initFaultStartAndEndNum();



    /**
     * 龙头凤尾质合互斥
     */
    $("input[type=checkbox][name='head']").change(function () {
        var obj = $(this);
        var val = obj.val();
        if (obj.prop("checked")) {
            $("input[type=checkbox][name='head']").not(this).attr("checked", false);
        }
    });
    $("input[type=checkbox][name='tail']").change(function () {
        var obj = $(this);
        var val = obj.val();
        if (obj.prop("checked")) {
            $("input[type=checkbox][name='tail']").not(this).attr("checked", false);
        }
    });

    $("#sumValueConditionWin input[type=checkbox][name='first']").change(function () {
        var obj = $(this);
        var val = obj.val();
        if (obj.prop("checked")) {
            $("input[type=checkbox][name='first']").not(this).attr("checked", false);
        }
    });

    $("#sumValueConditionWin input[type=checkbox][name='second']").change(function () {
        var obj = $(this);
        var val = obj.val();
        if (obj.prop("checked")) {
            $("input[type=checkbox][name='second']").not(this).attr("checked", false);
        }
    });


    /**
     * basic_pass_five  连传隔落 index
     */

    function refreshFiveThree() {
        let layerIndex = five_three;
        window['layui-layer-iframe' + layerIndex].location.reload();
    }

    // $("#refreash_five_three").click(function () {
    //     let layerIndex = five_three;
    //     window['layui-layer-iframe' + layerIndex].location.reload();
    // });

    $("#refreash_data").click(function () {
        dataInit();
    });

    $("#basic_pass_five").on('click', function () {
        layer.open({
            type: 2,
            title: '连传隔落',
            skin: 'layui-layer-rim', //加上边框
            area: ['1200px', '500px'], //宽高
            content: '/codeThree/passIndex',
            maxmin: true,
            shade: false,
            zIndex: layer.zIndex, //重点1
            success: function (layero) {
                layer.setTop(layero); //重点2
            }
        });

    });




    function code4Test(params) {
        $.post("/codeThree/dealWithTest", params, function (res) {
            let dataTypeName = "";
            if (params.dataType == 2) {
                dataTypeName = "北京飞艇";
            }
            if (params.dataType == 3) {
                dataTypeName = "排列5";
            }
            layer.msg('生成' + dataTypeName + '测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    }



    function code3FiveTestBtn(params) {
        $.post("/codeThree/dealWithFiveBtnTest", params, function (res) {
            let dataTypeName = "";
            dataTypeName = "排列5";
            layer.msg('生成' + dataTypeName + '测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    }

    $("#five-code3-test3").click(function () {
        var params = {
            testType: 1
        }
        code3FiveTestBtn(params);
    });
    $("#five-code3-test31").click(function () {
        var params = {
            testType: 2
        }
        code3FiveTestBtn(params);
    });
    $("#five-code3-test32").click(function () {
        var params = {
            testType: 3
        }
        code3FiveTestBtn(params);
    });

    $("#five-pre-three-01").click(function () {
        var params = {
            testType: 4
        }
        code3FiveTestBtn(params);
    });


    $("#boat-code4-test1").click(function () {
        var params = {
            dataType: 2,
            testType: 1
        }
        code4Test(params);
    });
    $("#boat-code4-test2").click(function () {
        var params = {
            dataType: 2,
            testType: 2
        }
        code4Test(params);
    });

    $("#danma_code_01").click(function () {
        var params = {
            key: testConfigKey.danma01,
            type: 3
        }
        $.post("/stat/dealWithDanmaTest", params, function (res) {
            layer.msg('生成' + '排列5【胆码01】测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    });



    var locationPreFun = function (params, msg) {
        $.post("/stat/dealWithTestThreeOne", params, function (res) {
            let dataTypeName = "";
            dataTypeName = "排列5";
            layer.msg('生成' + dataTypeName + '【' + msg + '】测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    }
    //传码个数
    $("#pass-code-number").click(function () {
        $.post("/stat/passCodeNumber", {}, function (res) {
            layer.msg('生成传码个数测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    });
    //一键01
    $("#five-showAll-01").click(function () {
        ////定位前3-1
        let P1 = new Promise(function (resolve, reject) {
            let params = {
                type: 3,
                testType: 21
            }
            $.post("/stat/dealWithTestThreeOne", params, function (res) {
                resolve();
            });
        });
        //前三胆码01
        let P2 = new Promise(function (resolve, reject) {
            let params = {
                testType: 1
            }
            $.post("/codeThree/dealWithFiveBtnTest", params, function (res) {
                resolve();
            });
        });
        //测试1-2
        let P3 = new Promise(function (resolve, reject) {
            let params = {
                dataType: 3,
                testType: 110
            };

            $.post("/codeThree/dealWithTest", params, function (res) {
                resolve();
            });
        });
        //测试2
        let P4 = new Promise(function (resolve, reject) {
            let params = {
                dataType: 3,
                testType: 2
            };
            $.post("/codeThree/dealWithTest", params, function (res) {
                resolve();
            });
        });


        Promise.all([P1, P2,P3,P4]).then(function (results) {
            layer.msg('一键01加载条件完成', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        })
    });
    $("#five-showAll-02").click(function () {

        //多个异步完成
        let P1 = new Promise(function (resolve, reject) {
            let params = {
                dataType: 3,
                testType: 11//测试2-1
            }
            $.post("/codeThree/dealWithTest", params, function (res) {
                console.log("p1");
                resolve();
            });
        });


        let P2 = new Promise(function (resolve, reject) {
            let  params = {
                dataType: 3,
                testType: 110
            }
            $.post("/codeThree/dealWithTest", params, function (res) {
                console.log("p2");
                resolve();
            });
        });
        let P3 = new Promise(function (resolve, reject) {
            let params = {
                dataType: 3
            }
            $.post("/test/dealWithTrendTest", params, function (res) {
                resolve();
            });
        });

        let P4 = new Promise(function (resolve, reject) {
            loactionPreThreeToOne();
            // let params = {
            //     type: 3,
            //     testType: 21
            // }
            // $.post("/stat/dealWithTestThreeOne", params, function (res) {
            //     console.log("p4");
            //     resolve();
            // });
        });

        let P5 = new Promise(function (resolve, reject) {
            let  params = {
                type: 3,
                testType: 24
            }
            $.post("/stat/dealWithTestThreeOne", params, function (res) {
                console.log("p5");
                resolve();
            });
        });


        Promise.all([P1, P2,P3,P4,P5]).then(function (results) {
            layer.msg('一键02加载条件完成', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        })

    });

    $("#code_four_2").click(function () {
        var params = {
            testType: 300
        };
        $.post("/codeThree/dealWithTestFourOne", params, function (res) {
            let dataTypeName = "";
            dataTypeName = "排列5";
            layer.msg('生成' + dataTypeName + '【代码4-1】测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });

    });

    //前三胆码
    $("#code_three-1").click(function () {
        var params = {
            type: 3,
            testType: 24
        }
        locationPreFun(params, '定位3-1');
    });

    $("#locate_pre_one-2").click(function () {
        var params = {
            type: 3,
            testType: 23
        }
        locationPreFun(params, '定位前1-2');
    });

    //定位前1 locate_pre_one
    $("#locate_pre_one").click(function () {
        var params = {
            type: 3,
            testType: 22
        }
        locationPreFun(params, '定位前1');
    });

    //定位前3-1
    function loactionPreThreeToOne(){
        var params = {
            type: 3,
            testType: 21
        }
        locationPreFun(params, '定位前3-1');
    }

    $("#locate_pre_three_1").click(function () {
        loactionPreThreeToOne();
    });


    $("#locate_pre_two").click(function () {
        var params = {
            type: 3,
            testType: 300
        }
        $.post("/stat/dealWithTestTwo", params, function (res) {
            let dataTypeName = "";
            if (params.dataType == 2) {
                dataTypeName = "北京飞艇";
            }
            if (params.dataType == 3) {
                dataTypeName = "排列5";
            }
            layer.msg('生成' + dataTypeName + '【定位前2】测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    });

    $("#locate_pre_three").click(function () {
        var params = {
            type: 3,
            testType: 2
        }
        $.post("/stat/dealWithTestThree", params, function (res) {
            let dataTypeName = "";
            if (params.dataType == 2) {
                dataTypeName = "北京飞艇";
            }
            if (params.dataType == 3) {
                dataTypeName = "排列5";
            }
            layer.msg('生成' + dataTypeName + '【定位前3】测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    });

    //生成两个胆码条件
    $("#five-code4-test1").click(function () {
        var params = {
            dataType: 3,
            testType: 100
        }
        $.post("/codeThree/dealWithTest", params, function (res) {
            var params = {
                dataType: 3,
                testType: 200
            }
            $.post("/codeThree/dealWithTest", params, function (res) {
                let dataTypeName = "";

                layer.msg('生成排列5测试数据!', {time: 1000}, function () {
                    layer.close(layer.index);
                    parent.location.reload();
                })
            });

        });


    });

    //dealWithTest
    $("#five-group-six").click(function () {
        var params = {
            dataType: 3,
            testType: 6//测试2-1
        }
        code4Test(params);
    });


    $("#five-code4-test21").click(function () {
        var params = {
            dataType: 3,
            testType: 5//测试2-1
        }
        code4Test(params);
    });

    $("#five-code4-test2").click(function () {
        var params = {
            dataType: 3,
            testType: 2
        }
        code4Test(params);
    });
    $("#five-code4-test12").click(function () {
        var params = {
            dataType: 3,
            testType: 110
        }
        code4Test(params);
    });

    $("#five-code4-test13").click(function () {
        var params = {
            dataType: 3,
            testType: 4
        }
        code4Test(params);
    });

    $("#five-code4-test14").click(function () {
        var params = {
            dataType: 3
        }
        $.post("/test/dealWithTrendTest", params, function (res) {
            let dataTypeName = "";
            if (params.dataType == 2) {
                dataTypeName = "北京飞艇";
            }
            if (params.dataType == 3) {
                dataTypeName = "排列5";
            }
            layer.msg('生成' + dataTypeName + '测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    });

    $("#five-code5-test11").click(function () {
        var params = {
            dataType: 3,
            testType: 11//测试2-1
        }
        code4Test(params);
    });

    $("#boat-code5-test3").click(function () {
        var params = {
            type: 2
        }
        $.post("/codeFive/dealWithTest", params, function (res) {
            layer.msg('生成北京飞艇测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    });
    $("#five-code5-test22").click(function () {
        var params = {
            type: 3
        }
        $.post("/codeFive/dealWithTest", params, function (res) {
            layer.msg('生成排列5测试数据!', {time: 1000}, function () {
                layer.close(layer.index);
                parent.location.reload();
            })
        });
    });

    /**
     * 将当前表格中所有处于选中状态对获取
     */

    function setConditionFault(param) {
        $.post("/index/setConditionFault", param, function (res) {
            //加载页面
            initCombinationTable(param.type);
        });
    }


    /**
     * 排列5容错发生勾选
     */
    $("#condition-table-five").on("change", ".fault-check", function () {
        var param = {
            isFault: $(this).is(":checked"),
            id: $(this).parent().parent().find(".con-id").eq(0).val(),
            type: 3
        };
        setConditionFault(param);
    })


        //复制codeFourFive.js内容 --start
        /**
             * 定义map
             * @param className
             * @param val
             */
            var selectNameMap1=new Map();
            var selectNameMap2=new Map();
            selectNameMap1.set("左","left");
            selectNameMap1.set("右","right");
            selectNameMap1.set("断","break1");
            selectNameMap1.set("","");
            selectNameMap2.set("落","fall");
            selectNameMap2.set("断","break2");
            selectNameMap2.set("","");



            function removeSublinsEleClass(className, val) {
                //直接是class名称
                if (val.hasClass(className)) {
                    //siblings参数是一个选择器
                    val.siblings("." + className).removeClass("btn-click-trend")
                }
            }

            //按钮点击  设置选中项的颜色
            $(".btn-nums-select").click(function () {
                var val = $(this);
                if (val.hasClass("btn-click-trend")) {
                    val.removeClass("btn-click-trend");
                } else {
                    val.addClass("btn-click-trend");
                    //如果有选择限制的，去掉有选择限制的其他元素的该样式 互斥
                    removeSublinsEleClass('firstValue', val);
                    removeSublinsEleClass('secondValue', val);

                }
            });

            //清空选中项的颜色
            $("#clear-trend").click(function () {
                $(".btn-nums-select").each(function () {
                    var numBtn = $(this);
                    if (numBtn.hasClass("btn-click-trend")) {
                        numBtn.removeClass("btn-click-trend")
                    }
                });
            });

            function getOccursCounts(paramArr) {
                var count = 0;
                for (var i = 0; i < paramArr.length; i++) {
                    if (paramArr[i] != '' && paramArr[i].length > 0) {
                        count++;
                    }
                }
                return count;
            }

            /**
             * 获取表格中同一类class的值，逗号分隔
             */

            function getTabletdTextClassName(tableId, tdClassName) {
                var obj = $("#" + tableId).find("." + tdClassName);
                var str = "";
                obj.each(function () {
                    if ($(this).hasClass("btn-click-trend")) {
                        str = str + $(this).text() + ",";
                    }
                });
                if (str.length > 0 && str.substr(str.length - 1) == ',') {
                    str = str.substring(0, str.length - 1);
                }
                return str;
            }

            //手动输入按钮确定
            $("#inputNumBtn").click(function(){
                let showType= localStorage.getItem("tableShowType");
                if(showType=="4"){
                     let str=$("#inputNumStrs").val();
                     if(str==undefined || str==''){
                        layer.msg('输入数据不合法');
                        return;
                     }
                     if(str.split(",").length!=3){
                        layer.msg('输入数据不合法');
                        return;
                     }
                 $.post("/codeThree/saveInputCode", {value:str}, function (res) {
                        if(res.status==0){
                           location.reload();
                        }else{
                          layer.msg('输入数据不合法');
                        }
                });
                }
            });

            $("#handInputBtn").click(function(){
                let showType= localStorage.getItem("tableShowType");
                console.log(showType);
                if(showType=="3"){
                    localStorage.setItem("tableShowType","4");
                }else{
                     localStorage.setItem("tableShowType","3");
                }
                showType= localStorage.getItem("tableShowType");
                 $.post("/codeThree/changeShowType", {type:showType}, function (res) {
                        location.reload();
                });
            });

            //点击代码4 提交按钮  danma
            $("#submit-choose-trend").click(function () {
                var danmas = getTabletdTextClassName("code3ValueTr", "danma");
                var frists = getTabletdTextClassName("code3ValueTr", "frist");
                var seconds = getTabletdTextClassName("code3ValueTr", "second");
                var thirds = getTabletdTextClassName("code3ValueTr", "third");
                var firstStatus = getTabletdTextClassName("code3ValueTr", "firstStatus");
                var secondStatus = getTabletdTextClassName("code3ValueTr", "secondStatus");
                var thirdStatus = getTabletdTextClassName("code3ValueTr", "thirdStatus");

                //胆码数据 --start
                 var danmaOccur=danmas.length>3?3:danmas.length;
                 var occur1Arr=[];
                for (var i =1 ; i <=danmaOccur; i++) {
                    occur1Arr.push(i);
                }
                //胆码数据 --end
                var paramArr = [frists, seconds, thirds];
                //最下面的0 1 2 3选项
                var occurs =0;// getOccursCounts(paramArr);//大的occurs
                if(frists.length>0 || firstStatus.length>0){
                    occurs++;
                }
                if(seconds.length>0 || secondStatus.length>0){
                    occurs++;
                }
                 if(thirds.length>0 || thirdStatus.length>0){
                    occurs++;
                }

                if (occurs == 0 && occur1Arr.length==0
                     && firstStatus==''
                     && secondStatus==''
                     && thirdStatus=='') {
                    layer.msg('所选项不能为空');
                    return;
                } else {
                    var firstOccurs = [];
                    if (frists.length>0){
                       let cout=frists.split(",").length;
                        for (var i = 0; i < cout; i++) {
                                firstOccurs.push(i + 1);
                         }
                    }

                    var secondOccurs = [];
                    if (seconds.length>0){
                       let cout=seconds.split(",").length;
                        for (var i = 0; i < cout; i++) {
                                secondOccurs.push(i + 1);
                         }
                    }
                    var thirdOccurs = [];
                    if (thirds.length>0){
                       let cout=thirds.split(",").length;
                        for (var i = 0; i < cout; i++) {
                                thirdOccurs.push(i + 1);
                         }
                    }

                    var params = {
                        firsts: frists,
                        firstOccurs:firstOccurs.join(","),
                        seconds: seconds,
                        secondOccurs:secondOccurs.join(","),
                        thirds: thirds,
                        thirdOccurs:thirdOccurs.join(","),
                        occurs: occurs,
                        regionsPredict:danmas,
                        occurTimesRegion:occur1Arr.join(","),
                        firstStatus:firstStatus,
                        secondStatus:secondStatus,
                        thirdStatus:thirdStatus,
                        type: 8,
                        dataType:3
                    };
                    //提交到后台到信息
                    $.post("/codeThree/dealWithCodeThree", params, function (res) {
                        layer.msg('成功将您预测的号码提交到"已选条件"里面!', {time: 1000}, function () {
                            layer.close(layer.index);
                            location.reload();
                        })
                    });
                }


            });


            //如果字符串不为空且以,结尾。则去掉最后一位
            function delStrEndwithComma(str) {
                if (str != null && str.length > 0) {
                    var last = str.substring(str.length - 1);
                    if (last == ',') {
                        return str.substring(0, str.length - 1);
                    }
                }
                return str;
            }
         //复制codeFourFive.js内容 --end
        //滚动条在最下
        var div = document.getElementById('fc-grid-table-div');
        div.scrollTop = div.scrollHeight;


})

//打开新窗口
function addTab(_this) {
    tab.tabAdd(_this);
}
